<?php
/**
 * 后台默认首页
 *
 * @author Alen
 * @since 1.0.0 2013-10-3 sutroon
 */
class IndexAction extends AdmincpAction {
    protected $biz;
    protected $tblobject;
    protected $search_params;
    public function __construct() {
        parent::__construct();
        $search_params= file_get_contents("php://input");
    }
    
    public function index(){
       switch($this->MODULE_NAME){
           case 'Finance_Account_List':               
                // 构建数据表格
                $this->begin_table('?m=Api/Article');
                $this->begin_table_button();
                $this->add_table_button('add','新增','?m=Article_Edit');
                $this->add_table_button('edit','编辑','?m=Article_Edit');
                $this->add_table_button('remove','删除','');
                $this->end_table_button();
                $this->begin_table_search();
                $this->add_table_search_combobox('关键词','kw');
                $this->end_table_search();
                $this->add_head(array('标题'=>'Title'));
                $this->end_table();
               break;
           case 'Login':
                $this->assign('u',request_string('u'));
                $this->assign('c',request_string('c'));
               break;
       }
        $this->set_page_info();
        
        // 显示模板内容
        $this->display();
    }
    
    public function update(){   
        $biz=new SoBizFinanceAccount();
        $msg=$biz->update_state(request_string('n'), request_numeric('v'));
        redirect($msg=='SUCCESS'?'状态编辑成功':$msg,'?m=Finance_Account_List&r=done');
    }
    public function delete(){    
        $biz=new SoBizArticle();
        $msg=$biz->delete_one(request_numeric('id'));
        if($msg=='SUCCESS'){
            redirect('删除成功!','?m=Article_List');
        }else{
            redirect($msg);
        }
    }
    public function login(){
        $biz=new SoBizUser(true);
        $msg=$biz->login_admin(request_string('UserName'),request_string('Password'));
        if($msg=='SUCCESS'){
            redirect('登录成功','?m=Index');
        }else{
            timer_die_or_redirect($msg,'logincount','?m=Login&r=fail');
        }
    }
    
    public function loginout(){
        $biz=new SoBizUser(true);
        $biz->login_out();
        $this->assign('u',request_string('u'));
        $this->assign('c',request_string('c'));
        $this->display();
}  

    public function set_page_info() {
        // 参数处理
        $w=request_string('keyword');
        // 局部变量
        $h1='';$h1p='';$title='';$h1panel='';
        // 设置面包屑导航
        $this->begin_breadcrumb();
        switch ($this->MODULE_NAME){
            case 'Index':
                $h1='';
                $h1p='欢迎使用WAUF网站管理系统';
                $title='首页';
                $this->add_breadcrumb('首页', '?m='.$this->MODULE_NAME.'.html');
                break;
            case 'Finance_Account_List':
                $h1='账户管理';
                $h1p='';
                $title=$h1;
                // 设置统计信息
                $biz=new SoBizFinanceAccount();
                $h1panel='<div class="easyui-panel page_summary" title="统计信息" style="padding:10px;">';
                $h1panel.='<table><tr>';
                $h1panel.='<td>会员可用总金额：<strong class="green">'.$biz->get_amount_all().'</strong></td>';
                $h1panel.='<td>会员总不可用余额：<strong class="red">'.$biz->get_amount_frozenblance().'</strong></td>';
                $h1panel.='</tr><tr>';
                $h1panel.='<td>System可用余额：<strong class="green">'.$biz->get_amount_system().'</strong></td>';
                $h1panel.='<td>购买坐席提成金额：<strong class="green">'.$biz->get_amount_comission().'</strong></td>';
                $h1panel.='</tr></table>';
                $h1panel.='</div>';
                break;
        }
        $this->end_breadcrumb();
        
        // 设置页面头部信息
        $this->assign_h1($h1,$h1p,$h1panel);
        
        // 设置页面Head信息,如页面标题,meta信息等
        $this->assign_page_head($title);        
    }
}

?>
